package com.jinbei.common.util;

import com.alibaba.fastjson.JSONObject;
import com.jinbei.common.contants.Contants;
import org.apache.commons.lang3.StringUtils;

import javax.servlet.http.HttpServletRequest;

/**
 * @author zflu
 * 获取authorization 工具类
 * Created by lucky on 2018/9/17.
 */
public class TokenUtil {

    public static JSONObject getToken(HttpServletRequest request){
        JSONObject json = null;
        String token = CookieUtil.getCookie(request, Contants.AUTHORIZATION);
        if(StringUtils.isNotBlank(token)){
            json = AuthorizationUtil.getUserByAuthorization(token);
        }
        return json;
    }
}
